import 'dart:convert';

class Message {
  final String? sendId;
  final String? acceptId;
  final String? username;
  final String? avatar;
  final int? count;
  final String? content;
  final String? date;
  final String? time;

  Message({
    required this.sendId,
    required this.acceptId,
    required this.username,
    required this.avatar,
    required this.count,
    required this.content,
    required this.date,
    required this.time,
  });

  factory Message.fromJson(Map<String, dynamic> json) {
    return Message(
      sendId: json['sendId'],
      acceptId: json['acceptId'],
      username: json['username'],
      avatar: json['avatar'],
      count: json['count'],
      content: json['content'],
      date: json['date'],
      time: json['time'],
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['sendId'] = sendId;
    data['acceptId'] = acceptId;
    data['username'] = username;
    data['avatar'] = avatar;
    data['count'] = count;
    data['content'] = content;
    data['date'] = date;
    data['time'] = time;
    return data;
  }
}

class MessageList {
   List<Message>? messages;

  MessageList({required this.messages});

  factory MessageList.fromJson(List<dynamic> json) {
    return MessageList(
      messages: (json).map((item) => Message.fromJson(item)).toList(),
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['data'] = messages!.map((item) => item.toJson()).toList();
    return data;
  }
}
